import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/pages/Index'
import Detail from '@/pages/Detail'
import Reg from '@/pages/Reg'
import Login from '@/pages/Login'
import Category from '@/pages/Category'
import Tag from '@/pages/Tag'

Vue.use(Router)

const router = new Router({
    routes: [
        {
            path: '/',
            name: Index.name,
            component: Index
        },
        {
            path: '/detail',
            name: Detail.name,
            component: Detail
        },
        {
            path: '/reg',
            name: Reg.name,
            component: Reg
        },
        {
            path: '/login',
            name: Login.name,
            component: Login
        },
        {
            path: '/category',
            name: Category.name,
            component: Category
        },
        {
            path: '/tag',
            name: Tag.name,
            component: Tag
        }
    ]
})

router.beforeEach((to, from, next) => {
    //if(to.name === 'Reg'){
        $('body').removeClass();   //去除侧栏切换时，body样式残余
    //}
    next();
})

export default router